package com.story.api.moduler.song.service.impl;

import com.story.api.moduler.song.dao.PlayCountDao;
import com.story.api.moduler.song.dao.UseAppDao;
import com.story.api.moduler.song.service.StatisticsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author Administrator
 * @decription
 * @Date 2018-05-11 10:22
 */
@Service
public class StatisticsServiceImpl implements StatisticsService {

    @Autowired
    private UseAppDao useAppDao;

    @Autowired
    private PlayCountDao playCountDao;

    @Override
    public void statisticsUseApp() {
        int existCount = useAppDao.existTodayUseCount();
        if(existCount < 1) {
            useAppDao.insertCurrentDayUseCount();
        } else {
            useAppDao.updateCurrentDayUseCount();
        }
    }

    @Override
    public void statisticsPlayCount() {
        int existCount = playCountDao.existTodayPlayCount();
        if(existCount < 1) {
            playCountDao.insertCurrentDayPlayCount();
        } else {
            playCountDao.updateCurrentDayPlayCount();
        }
    }
}
